<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>发货单</title>
		<script src="/js/vue.js"></script>
		<script src="/js/axios.js"></script>
		<script src="/js/qs.js"></script>
		<script src="/js/jquery.min.js"></script>
		<script src="//unpkg.com/element-ui@2.4.11/lib/index.js"></script>
		<style scoped>
			/* 在此定义当前页面css */
			@import url("//unpkg.com/element-ui@2.4.11/lib/theme-chalk/index.css");
		</style>
		<style type="text/css">
			#app {
				/* border:1px #dee1eb solid; */
			}

			#max {

				margin: 0 auto;
				margin-top: 40px;
				margin-bottom: 40px;
				width: 95%;
				background-color: white;
			}

			#max1 {

				margin: 0 auto;
				margin-bottom: 40px;
				width: 95%;

			}

			.table1 {
				margin: 0 auto;
				width: 80%;
			}

			.table1 tr {
				height: 40px;

			}

			.td1 {
				width: 10%;
				font-size: 12px;
				/* border-bottom:1px solid black; */
				/* border: 1px #e5e5e5 solid; */
				/* background-color: #F9F9F9; */
			}

			.td2 {
				font-size: 12px;
				text-align: left;
				width: 40%;
			}

			.el-table__header th,
			.el-table__header tr {
				background-color: #dee1e6;
				color: black;
				font-size: 12px;
				line-height: 20px;
			}

			#appreturnleft {
				background-color: white;
				border: 1px #dee1eb solid;
			}

			#appreturnright {
				background-color: white;
				border: 1px #dee1eb solid;
			}
		</style>
	</head>
	<body style="background-color: #f4f8fb;">
		<div id="max" style="border-radius: 1%;">
			<div id="apphard" style="overflow:hidden ;border-radius: 3%;">
				<span style="font-size: 18px; margin-left:  10px; line-height: 60px;">退货单</span>
			</div>
			
				<hr />
				<el-form ref="repform" label-width="100px" class="demo-repform" style="width: 90%;margin-top: 20px;margin-left:4%;">
					<el-row>
						<el-col :span="10" style="margin-left:50px;">
							<el-form-item label="订单:" label-width="120px">
								<div style="border-bottom: 1px solid #DCDCDC;height: 35px;font-size: 15px;">${refundgood.title} </div>
							</el-form-item>
						</el-col>
						<el-col :span="10" style="margin-left:40px;">
							<el-form-item label="处理人:" label-width="120px">
								<div style="border-bottom: 1px solid #DCDCDC;height: 35px;font-size: 15px;">${refundgood.u_name} </div>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="10" style="margin-left:50px;">
							<el-form-item label="退货日期:" label-width="120px">
								<div style="border-bottom: 1px solid #DCDCDC;height: 35px;font-size: 15px;">${refundgood.data} </div>
								<!-- <div style="border-bottom: 1px solid #DCDCDC;height: 35px;font-size: 15px;">
									<span v-if="boodate">
										{{date}}
									</span>
									<span v-if="!boodate">
										${outgood.deliverydate}
									</span>
								</div> -->
							</el-form-item>
						</el-col>
						<el-col :span="10" style="margin-left:40px;">
							<el-form-item label="退货单号:" label-width="120px">
								<div style="border-bottom: 1px solid #DCDCDC;height: 35px;font-size: 15px;">${refundgood.rgId}</div>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="10" style="margin-left:50px;">
							<el-form-item label="退货状态:" label-width="120px">
								<div style="border-bottom: 1px solid #DCDCDC;height: 35px;font-size: 15px;">
									<span style="color: red; font-weight: 600;" v-if="'${refundgood.srefundstatus}'=='1'">
										退货中
									</span>
									<span style="color: red; font-weight: 600;" v-if="'${refundgood.srefundstatus}'=='2'">
										已完成
									</span>
									
								</div>
								
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col style="margin-left:50px;">
							<el-form-item label="退货明细:"  label-width="120px">
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col style="margin-left:50px;">
							<div style="margin: 0 auto; width:90%; margin-bottom: 40px;" >
								<template>
							<el-table :data="tableData" border style="margin: 0 auto; border-radius: 10px; " :summary-method="getSummaries"
							 show-summary>
								<el-table-column prop="p_name" width="150px" label="产品名" align="center">
								</el-table-column>
								<el-table-column prop="p_name"  width="150px" label="型号" align="center">
								</el-table-column>
								<el-table-column prop="riCount"  width="100px" label="数量" align="center">
								</el-table-column>
								<el-table-column prop="p_unit"  width="100px" label="单位" align="center">
								</el-table-column>
								<el-table-column prop="riPrice"  width="100px" label="单价" align="center">
								</el-table-column>
								<el-table-column prop="riMoney"  width="150px" label="金额" align="center">
								</el-table-column>
								<el-table-column prop="riResult" show-overflow-tooltip label="退货原因" align="center">
								</el-table-column>
							</el-table>
						</template>
							</div>
						</el-col>
					</el-row>
				<div style="height: 100px; margin: 0 auto; margin-top: 20px; margin-bottom: 50px; width: 145px;" v-if="'${refundgood.srefundstatus}'=='1'" >
					<el-button type="primary" @click="querefundgood" size="medium"  >确认退货</el-button>
				</div>
				</div>
		</div>
		<script type="text/javascript">
			var datenew = new Date();
			var tables = ${
				refundgoodit
			};
			var max = new Vue({
				el: "#max",
				data: {
					repform: [],
					activeNames: [],
					boodate: false,
					oid: '${outgood.oId}',
					ogId: '${outgood.ogId}',
					uidloading: false,
					dialogAddressVisible:false,
					dialogPhysicalVisible: false,
					dialogPhysicalVisible1:false,
					osignloading1: false,
					tableData: tables,
					restaurants: [],
					
					
					date1: datenew.getFullYear() + "-" + (datenew.getMonth() + 1) + "-" + datenew.getDate(),
				},
				methods: {
					getSummaries(param) {
						const {
							columns,
							data
						} = param;
						const sums = [];
						columns.forEach((column, index) => {
							if (index === 0) {
								sums[index] = '总计';
								return;
							}
							const values = data.map(item => Number(item[column.property]));
											
							if (!values.every(value => isNaN(value))) {
								sums[index] = values.reduce((prev, curr) => {
									const value = Number(index);
											
									if (!isNaN(value) && index != 3) {
										return prev + curr;
									} else {
										return '';
									}
											
								}, 0);
								if (index == 4 || index == 5) {
									sums[index] = sums[index].toFixed(2);
								}
								if (index == 1 || index == 3 || index == 4  || index == 6)
									sums[index] = '---';
								if (index == 5)
									sums[index] += ' 元';
							} else {
								sums[index] = '';
							}
						});
						return sums;
					},
					
					querefundgood(){
						axios.post("/sales/prosale/updaterefundtype",
							//参数转换
							Qs.stringify({
								'rgid':${refundgood.rgId},
								'oid':${refundgood.oId}
							},
							{arrayFormat: 'brackets'})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data.contact);
							window.location.href = '/sales/prosale/orderView?id=' + ${refundgood.oId};
						}).catch(function() {
							alert("信息出错了");
						});
					}
				}
					
				

			})
		</script>
	</body>
</html>
